﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Edu.Web.Data.DV;
using Edu.Web.Data.Entity;

namespace Edu.Web.Data.DAO.Impl
{
    public partial class NoticeDAO
    {
        public IQueryable<NoticeDV> GetNoticeList()
        {
            return from notice in Db.Set<NoticeEntity>()
                   join user in Db.Set<UserEntity>() on notice.CreateUserId equals user.Id
                   join cource in Db.Set<CourceEntity>() on notice.CourceId equals cource.Id
                   into tt
                   from t in tt.DefaultIfEmpty()
                   select new NoticeDV
                   {
                       Content = notice.Content,
                       CreateUserId = notice.CreateUserId,
                       CreateTime = notice.CreateTime,
                       CreateUserName = user.RealName,
                       CourceId = notice.CourceId,
                       CourceName = t != null ? t.CourceName : "",
                       Title = notice.Title,
                       Id = notice.Id,
                       NoticeType = notice.NoticeType
                   };
        }
    }
}